package com.qeegoo.b2bautozityp.moudle.good.view;

import android.content.Intent;

import com.cropper.imagepicker.ImagePicker;
import com.qeegoo.b2bautozityp.R;
import com.qeegoo.b2bautozityp.databinding.FragGoodsInfoBinding;
import com.qeegoo.b2bautozityp.injector.component.DaggerGoodsFragmentComponent;
import com.qeegoo.b2bautozityp.moudle.base.BaseFragment;
import com.qeegoo.b2bautozityp.moudle.good.viewmodel.GoodsInfoViewModel;

import javax.inject.Inject;

import base.lib.widget.recyclerview.DividerLinearItemDecoration;

/**
 * 王少岩 在 2017/9/14 创建了它
 */

public class GoodsInfoFragment extends BaseFragment<FragGoodsInfoBinding> {
    @Inject
    GoodsInfoViewModel mViewModel;
    @Inject
    ImagePicker mImagePicker;

    public static GoodsInfoFragment newsIntance(){
        GoodsInfoFragment fragment = new GoodsInfoFragment();
        return fragment;
    }

    @Override
    protected int attachLayoutRes() {
        return R.layout.frag_goods_info;
    }

    @Override
    protected void initInjector() {
        DaggerGoodsFragmentComponent.builder().appComponent(getAppComponent()).fragmentComponent(getFragmentComponent()).build().inject(this);
    }

    @Override
    protected void initViews() {
        mViewModel.setImgs(mImagePicker);
        mBinding.setViewModel(mViewModel);
        mBinding.rvGoodsInfo.addItemDecoration(new DividerLinearItemDecoration(getActivity(), DividerLinearItemDecoration.HORIZONTAL_LIST, R.drawable.divider_h));
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        mImagePicker.onActivityResult(this, requestCode, resultCode, data);
    }

    public GoodsInfoViewModel getViewModel() {
        return mViewModel;
    }
}
